package com.zycfc.zsf.boot.logback.core;

import java.io.*;
import com.zycfc.zsf.boot.util.text.*;

public class SqlLogInfBuilder implements Serializable
{
    private static final long serialVersionUID = 1L;
    private String sqlId;
    private String sqlName;
    private String sqlClassPath;
    private String sqlMethod;
    private String sqlCommandType;
    private String datasourceType;
    private String sql;
    private long exeTm;
    private String exeSts;
    private String sqlParamJson;
    private String respCode;
    private String respMsg;
    private Integer totalCount;
    
    public String getSqlId() {
        return this.sqlId;
    }
    
    public SqlLogInfBuilder setSqlId(final String sqlId) {
        this.sqlId = sqlId;
        if (StringUtils.isEmpty(sqlId)) {
            return this;
        }
        final String[] array = sqlId.split("\\.");
        if (array.length > 2) {
            this.sqlName = array[array.length - 2] + "." + array[array.length - 1];
            this.sqlMethod = array[array.length - 1];
            this.sqlClassPath = sqlId.substring(0, sqlId.lastIndexOf("."));
        }
        return this;
    }
    
    public String getSqlCommandType() {
        return this.sqlCommandType;
    }
    
    public SqlLogInfBuilder setSqlCommandType(final String sqlCommandType) {
        this.sqlCommandType = sqlCommandType;
        return this;
    }
    
    public String getDatasourceType() {
        return this.datasourceType;
    }
    
    public SqlLogInfBuilder setDatasourceType(final String datasourceType) {
        this.datasourceType = datasourceType;
        return this;
    }
    
    public String getSql() {
        return this.sql;
    }
    
    public SqlLogInfBuilder setSql(final String sql) {
        this.sql = sql;
        return this;
    }
    
    public long getExeTm() {
        return this.exeTm;
    }
    
    public SqlLogInfBuilder setExeTm(final long exeTm) {
        this.exeTm = exeTm;
        return this;
    }
    
    public String getSqlParamJson() {
        return this.sqlParamJson;
    }
    
    public SqlLogInfBuilder setSqlParam(final Object sqlParamObject) {
        if (sqlParamObject == null) {
            return this;
        }
        this.sqlParamJson = (String)((sqlParamObject instanceof String) ? sqlParamObject : "");
        return this;
    }
    
    public String getRespCode() {
        return this.respCode;
    }
    
    public SqlLogInfBuilder setRespCode(String respCode) {
        if (StringUtils.isEmpty(respCode)) {
            return this;
        }
        if (respCode.length() > 10) {
            respCode = respCode.substring(0, 10);
        }
        this.respCode = respCode;
        return this;
    }
    
    public String getRespMsg() {
        return this.respMsg;
    }
    
    public SqlLogInfBuilder setRespMsg(String respMsg) {
        if (StringUtils.isEmpty(respMsg)) {
            return this;
        }
        if (respMsg.length() > 200) {
            respMsg = respMsg.substring(0, 200);
        }
        this.respMsg = respMsg;
        return this;
    }
    
    public String getExeSts() {
        return this.exeSts;
    }
    
    public SqlLogInfBuilder setExeSts(final String exeSts) {
        this.exeSts = exeSts;
        return this;
    }
    
    public String getSqlName() {
        return this.sqlName;
    }
    
    public String getSqlClassPath() {
        return this.sqlClassPath;
    }
    
    public String getSqlMethod() {
        return this.sqlMethod;
    }
    
    public Integer getTotalCount() {
        return this.totalCount;
    }
    
    public SqlLogInfBuilder setTotalCount(final Integer totalCount) {
        this.totalCount = totalCount;
        return this;
    }
    
    public SqlLogInf build() {
        return new SqlLogInf(this);
    }
}
